<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 全局作用域 跨越script标签使用
      var myname = 'cxm'

      // 局部作用域  只有函数能够生成一个局部作用域
      function test() {
        console.log('test')
        var nickname = 'xmxm'
        console.log(nickname) //undefined
      }
      // console.log(nickname) //nickname is not defined
    </script>

    <script>
      console.log(myname)
      console.log(test)
      //ƒ test() {
      // console.log('test')
      // }
    </script>
  </body>
</html>
